<template>
    <el-card shadow="never">
        <yun-table
            :columns="columns"
            ref="yuntable"
            toolbar="refresh,addgoods,del"
            :auth="{
                del:{:$auth->check('app\\admin\\controller\\delivery\\channel\\CustomerGoods','del')},
            }"
            :add-form="{width:800,height:500}"
            :common-search="false"
            :extend="extend">
            <template #toolbar="{tool}">
                <el-button v-if="tool=='addgoods'" @click.stop="addGoods" type="primary"><i class="fa fa-plus"></i>&nbsp;添加</el-button>
            </template>
        </yun-table>
    </el-card>
</template>
<script>
    import table from "@components/Table.js";
    export default{
        components:{
            'YunTable':table,
        },
        data:{
            customer_id:'',
            extend:'',
            columns:[
                {checkbox: true},
                {field: 'goods.name', title: '商品名称',operate:false},
                {field: 'spec.name', title: '商品规格',operate:false},
                {field: 'price', title: '商品单价',operate:false},
            ],
        },
        onLoad(e){
            this.customer_id=e.customer_id;
            this.extend={
                index_url: 'delivery/channel-customer-goods/index?customer_id='+e.customer_id,
                del_url: 'delivery/channel-customer-goods/del?customer_id='+e.customer_id,
            }
        },
        methods: {
            addGoods:function (e){
                let that=this;
                Yunqi.api.open({
                    title:'添加商品',
                    url:'delivery/channel-customer-goods/add?customer_id='+this.customer_id,
                    icon:'fa fa-plus',
                    close:function (e){
                        if(e){
                            that.$refs.yuntable.reload();
                        }
                    }
                });
            }
        }
    }
</script>
<style>

</style>